using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIController : MonoBehaviour
{
    public GameObject gameStartPanel;
    public GameObject gameOverPanel;
    public Button gameStartButton;
    public Button playAgainButton;

    protected void Awake()
    {


        gameStartButton.onClick.AddListener(() =>
        {
            Global.instance.StartGame();
            HideGameStartPanel();
        });

        playAgainButton.onClick.AddListener(() =>
        {
            Global.instance.RestartGame();
            HideGameOverUI();
        });

        EventManager.GetInstance.StartListening("uiStart", ShowGameStartPanel);
        EventManager.GetInstance.StartListening("uiOver", ShowGameOverUI);
    }
   

    private void OnDestroy()
    {
        EventManager.GetInstance.StopListening("uiStart", ShowGameStartPanel);
        EventManager.GetInstance.StopListening("uiOver", ShowGameOverUI);
    }

    public void ShowGameStartPanel()
    {
        gameStartPanel.SetActive(true);
    }

    public void HideGameStartPanel()
    {
        gameStartPanel.SetActive(false);
    }

    public void ShowGameOverUI()
    {
        gameOverPanel.SetActive(true);
    }

    public void HideGameOverUI()
    {
        gameOverPanel.SetActive(false);
    }
}
